<template>
    <div class="header-top" style="-webkit-app-region: drag;">
        <div class="left">
            <div>{{ userName }}</div>
        </div>
        <div class="right">
            <div class="minimize" style="flex: 1;" @click="minimize"><img style="margin: 14px 0 0 14px;"
                    src="../assets/minimize.png">
            </div>
            <div class="info_v" style="flex: 1;" @click="toInfo"><img style="margin: 14px 0 0 14px;"
                    src="../assets/info_v.png">
            </div>
            <div class="close" style="flex: 1;" @click="close"><img style="margin: 14px 0 0 14px;"
                    src="../assets/close.png">
            </div>
        </div>
    </div>
</template>

<script>
const { ipcRenderer } = window.require('electron')
import { mapGetters } from "vuex";
export default {
    name: 'HeaderTop',
    data() {
        return {
            userName: ''
        }
    },
    created() {
        this.getUserName()
    },
    methods: {
        ...mapGetters(['getStoreUserInfo']),
        // 最小化
        minimize() {
            ipcRenderer.send('detach:vue', { type: 'minimize' })
        },
        // 去版本信息页
        // toInfo() {
        //     this.$router.push('/info_v');
        // },
        // 关闭
        close() {
            ipcRenderer.send('detach:vue', { type: 'close' })
        },
        // 获取用户名字
        async getUserName() {
            const userInfo = this.getStoreUserInfo()
            console.log(userInfo);
            if (userInfo.displayName) {
                this.userName = this.getStoreUserInfo().displayName + '#' + this.getStoreUserInfo().tagLine
            } else {
                this.userName = '召唤师XXX'
            }
        }
    }
}
</script>

<style lang="scss" scoped>
@import '../assets/common.scss';

.header-top {
    display: flex;
    justify-content: space-between;
    width: 100%;
    height: 60px;
    padding-left: 40px;
    background-color: $t-b-color;
    line-height: 60px;
    border-radius: 0 10px 0 0;
    box-sizing: border-box;
    -webkit-app-region: drag;

    .left {
        padding: 10px 0 10px 0;
        height: 20px;
        color: $text-color;
        border-radius: 10px;

        div {
            width: 260px;
            height: 40px;
            padding: 0 20px 0 20px;
            border-radius: 10px;
            font-weight: bold;
            line-height: 40px;
            // color: $t-b-text-color;
            background-color: #fff;
        }
    }

    .right {
        display: flex;
        width: 180px;
        -webkit-app-region: no-drag;

        .minimize:hover {
            border-radius: 10px;
            cursor: pointer;
            background-color: #f9f9f9;
        }

        .info_v:hover {
            border-radius: 10px;
            cursor: pointer;
            background-color: #FFDA79;
        }

        .close:hover {
            border-radius: 10px;
            cursor: pointer;
            background-color: #FF5252;
        }
    }

}
</style>